<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录 | BoPress</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <link href="{{static_url('theme/bootstrap/css/bootstrap.min.css')}}" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="{{static_url('theme/font-awesome/css/font-awesome.min.css')}}" rel="stylesheet">
    <!-- Ionicons -->
    <link href="{{static_url('theme/ionicons2/css/ionicons.min.css')}}" rel="stylesheet">
    {%
    set htmls = apply_filters("bo_user_login_header", list(), handler)
    %}
    {% raw "".join(htmls) %}
    <!-- Theme style -->
    <link href="{{static_url('theme/css/AdminLTE.min.css')}}" rel="stylesheet">
    <!-- iCheck -->
    <link href="{{static_url('theme/plugins/iCheck/square/blue.css')}}" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="{{static_url('js/html5shiv.min.js')}}"></script>
    <script src="{{static_url('js/respond.min.js')}}"></script>
  <![endif]-->
    <style type="text/css">
        body,
        table,
        input,
        textarea,
        select,
        button,
        a,
        p,
        h1,
        h2,
        h3,
        h4,
        h5,
        div {
            font-family: "Microsoft YaHei", Verdana, sans-serif, "SimSun";
        }
    </style>
</head>

<body class="hold-transition login-page">
    <div class="login-box">
        <div class="login-logo">
            <a href="../../index2.html"><b>Bo</b>Press</a>
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">

            <form action="{{reverse_url('login')}}" method="post" id="login-form">
                <div class="form-group has-feedback">
                    <input type="text" class="form-control" placeholder="邮箱" name="user_email">
                    <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
                </div>
                <div class="form-group has-feedback">
                    <input type="password" class="form-control" placeholder="密码" name="user_pass">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                </div>
                <div class="row">
                    <div class="col-xs-8">
                        <div class="checkbox icheck">
                            <label>
              <input type="checkbox"> 记住我
            </label>
                        </div>
                    </div>
                    <!-- /.col -->
                    <div class="col-xs-4">
                        <button type="button" class="btn btn-primary btn-block btn-flat" onclick="login_func();">登录</button>
                    </div>
                    <!-- /.col -->
                </div>
            {%
                set htmls = apply_filters("bo_user_loginform", list(), handler)
            %}
            {% raw "".join(htmls) %}
            </form>
            {%
                set htmls = apply_filters("bo_user_loginform_footer", list(), handler)
            %}
            {% raw "".join(htmls) %}
            <a href="#" data-toggle="modal" data-target="#bo_pass_findback_dlg">忘记密码</a><br>
            <a href="{{reverse_url('registry')}}" class="text-center">注册新用户</a>

        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
    <div class="modal fade" id="bo_pass_findback_dlg" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">密码找回</h4>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <label for="fb_user_email" class="control-label">邮箱:</label>
                            <input type="email" class="form-control" id="fb_user_email" name="fb_user_email">
                            <span class="help-block">密码将重置并发送到您的邮箱，登录后可自行修改</span>
                            <span id="pass-findback-label" style="color:red;"></span>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="bo_pass_findback_btn">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- jQuery 2.2.3 -->
    <script src="{{static_url('theme/plugins/jQuery/jquery-2.2.3.min.js')}}"></script>
    <!-- Bootstrap 3.3.6 -->
    <script src="{{static_url('theme/bootstrap/js/bootstrap.min.js')}}"></script>
    <!-- iCheck -->
    <script src="{{static_url('theme/plugins/iCheck/icheck.min.js')}}"></script>
    <script src="{{static_url('js/bo-alert.js')}}"></script>
    <script>
        function login_func() {
            $.post("{{reverse_url('login')}}", $("#login-form").serialize(), function(rsp) {
                if (rsp.success) {
                    if(rsp.data.next.length>0){
                        window.location.href = rsp.data.next;
                    }else{
                        window.location.href = "{{reverse_url('admin')}}";
                    }
                } else {
                    bo_valid_errors("login-form", rsp.data, rsp.message);
                }
            }, "json");
        }
        $(function() {
            $("#bo_pass_findback_btn").click(function() {
                if ($.trim($("#fb_user_email").val()).length == 0) {
                    return;
                }
                $.post("{{reverse_url('verify')}}", {
                    "email": $("#fb_user_email").val()
                }, function(rsp) {
                    if (rsp.success) {
                        $("#pass-findback-label").html("新的密码已发送到您的邮箱");
                    } else {
                        bo_valid_errors("login-form", rsp.data, rsp.message);
                    }
                }, "json");
            });
            $('input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' // optional
            });
        });
    </script>
    {%
    set htmls = apply_filters("bo_user_login_footer", list(), handler)
    %}
    {% raw "".join(htmls) %}
</body>

</html>